<?php
	namespace Admin\Controller;
	use       Think\Controller;
	class RuleController extends PublicController{
	//输出权限列表
		public function index()
		{
			//实例化model类
			$rule = M('auth_rule');

			//计算数据库总条数
			$count = $rule->count();

			//实例化分页类
			$page = new \Think\Page($count,10);
			
			//分页配置
			$page->setConfig('header','个会员');
			$page->setConfig('first','首页');
			$page->setConfig('last','尾页');
			$page->setConfig('prev','上一页');
			$page->setConfig('next','下一页');
			$page->setConfig('theme','共 %TOTAL_ROW% 记录 %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%');
			
			//查询数据库信息
			$data = $rule->limit($page->firstRow.','.$page->listRows)->select();

			$show = $page->show();
			//dump($show);exit;

			//赋值变量
			$this->assign('show',$show);
			$this->assign('data',$data);
			$this->assign('aa',1);


			//输出模版
			$this->display();
		}

		//跳转到添加页面
		public function add()
		{
			//输出模版

			$this->display();
		}

		//执行添加方法
		public function insert()
		{
			//实例化model类
			$rule = M('auth_rule');

			//执行添加方法
			$res = $rule->add(I('post.'));
			//echo $rule->_sql();exit;
			if($res){
				$this->success('添加成功',U('Rule/index'),2);
			}else{
				$this->error('添加失败');
			}
		} 

	}